﻿#region Copyrights Notice
//©2010 Microsoft Corporation. All rights reserved.
#endregion

#region usings
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using Microsoft.InformationSecurity.CISF.SecurityPortal.Business.Widget;
using Microsoft.Security.Application;
using System.Data;
#endregion

namespace Microsoft.InformationSecurity.CISF.SecurityPortal.UI.Web.Widgets.QuickLinks
{
    public partial class QuickLinks : System.Web.UI.UserControl, IWidget
    {
        public string thisWidgetPath;
        private IWidgetContainer _WidgetContainer;

        protected void Page_Load(object sender, EventArgs e)
        {
            //updating the widget path from the container implementation
            thisWidgetPath = this._WidgetContainer.WidgetPath;

            this.LoadQuickLinks(sender, e);
        }
        protected void LoadQuickLinks(object sender, EventArgs e)
        {
            this.ShowQuickLinks();
        }

        protected void ShowQuickLinks()
        {
            try
            {
                DataSet dataSet = new DataSet();
                dataSet.ReadXml(Server.MapPath(thisWidgetPath+"\\QuickLinks.xml"));
                this.gridQuickLinks.DataMember = "QuickLink";
                this.gridQuickLinks.DataSource = dataSet;
                this.gridQuickLinks.DataBind();
            }
            catch
            {
                gridQuickLinks.Visible = false;
                lblResults.Text = "<img src='MasterUI/Images/Error-32.png' width='32' align='middle'></img> " + "Error rendering Quick Links!";
            }
        }
        #region Widgets Override
        void IWidget.OnControlInitilize(IWidgetContainer webContainer)
        {
            this._WidgetContainer = webContainer;
        }
        void IWidgetActions.UpdateSettings()
        {

        }
        void IWidgetActions.DisplaySettings(bool bDisplay)
        {
            SettingsPanel.Visible = bDisplay;
        }
        void IWidgetActions.Minimize()
        {
        }
        void IWidgetActions.Maximize()
        {
        }
        void IWidgetActions.Close()
        {

        }
        void IWidgetActions.MaximizeToFullScreen()
        {
        }
        #endregion
    }
}